//
//  BookCell.m
//  practise3
//
//  Created by 千锋 on 15/11/28.
//  Copyright (c) 2015年 abc. All rights reserved.
//

#import "BookCell.h"

@implementation BookCell
{
    UIImageView * _imageView;
    UILabel * _titleLabel;
    UILabel * _detailLABEL;
    UILabel * _PriceLabel;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

//创建UI
-(void)layoutSubviews
{
    if (!_imageView) {
        _imageView=[[UIImageView alloc]init];
        //添加到单元格上，自定义要加到ContentView上
        [self.contentView addSubview:_imageView];
    }
    if (!_titleLabel) {
        _titleLabel=[[UILabel alloc]init];
        [self.contentView addSubview:_titleLabel];
        _titleLabel.font=[UIFont systemFontOfSize:20];
    }
    if (!_detailLABEL) {
        _detailLABEL=[[UILabel alloc]init];
        [self.contentView addSubview:_detailLABEL];
        _detailLABEL.font=[UIFont systemFontOfSize:20];
        _detailLABEL.numberOfLines=0;
    }
    if (!_PriceLabel)
    {
        _PriceLabel=[[UILabel alloc]init];
        [self.contentView addSubview:_PriceLabel];
        _PriceLabel.font=[UIFont systemFontOfSize:20];
        
    }
    //设置位置
    CGSize cellSize=self.frame.size;
    _imageView.frame=CGRectMake(5, 10, cellSize.height-20, cellSize.height-20);
    _titleLabel.frame=CGRectMake(CGRectGetMaxX(_imageView.frame)+10, CGRectGetMinY(_imageView.frame), cellSize.width-CGRectGetMaxX(_imageView.frame)-20, 20);
    _detailLABEL.frame=CGRectMake(CGRectGetMinX(_titleLabel.frame), CGRectGetMidY(_imageView.frame)-20, CGRectGetWidth(_titleLabel.frame), 40);
    _PriceLabel.frame=CGRectMake(CGRectGetMinX(_titleLabel.frame), CGRectGetMaxY(_imageView.frame)-20, CGRectGetWidth(_titleLabel.frame), 20);
    

//赋值
    _imageView.image=[UIImage imageNamed:self.book.icon];
    _titleLabel.text=self.book.title;
    _detailLABEL.text=self.book.detail;
    _PriceLabel.text=self.book.price;

}
@end























